<!doctype html>
<html>

<head>
  <meta charset="UTF-8">
  <title>手动存积分</title>
  <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  <script>
    document.documentElement.style.fontSize = document.documentElement.clientWidth / 6.4 + 'px';
  </script>
  <link href="../../css/mui.min.css" rel="stylesheet" />
  <style>
    html {
      font-family: Roboto, Arial, "Noto Sans CJK SC", "Noto Sans CJK TC", "Pingfang SC", "Microsoft Yahei", "WenQuanYi Micro Hei", sans-serif;
      height: 100%;
    }

    body {
      overflow-x: hidden;
      text-align: center;
    }
    p{
      color:black;
      margin: 0;
    }

    .userInfoTitle{
      width: 100%;
      padding: 0.3rem 0;
      background-color: white;
      overflow: hidden;
      border-bottom: 1px solid #AAAAAA;
    }
    .userInfoTitle> div{
      float: left;
    }
    .userInfoTitle p{
      text-align: left;
    }
    .userImg{
      width: 1.2rem;
      height: 1.2rem;
      border-radius: 0.6rem;
      overflow: hidden;
      margin-right: 0.3rem;
      margin-left: 0.3rem;
    }
    .userImg img{
      width: 1.2rem;
    }



    .mask{
      width: 100%;
      height: 100%;
      position: fixed;
      bottom: 0;
      background-color: rgba(0, 0, 0, 0.2);
    }
    .sureBtn{
      width: 60%;
      color:white;
      background-color:#FF7100;
      margin: 0.8rem auto 0 ;
      padding: 0.2rem 0;
      text-align: center;
      font-size: 0.28rem;
    }
    .mask>.sureDiv{
      width: 80%;
      height: 3rem;
      border-radius: 0.2rem;
      background-color: white;
      margin: 3rem auto 0;
      border: 1px solid transparent;
    }
    .sureDiv p{
      margin-top: 1rem;
      font-size: 0.28rem;
      color:#FF7100;
    }
    .sureDiv button{
      width: 1.4rem;
      height: 0.6rem;
      line-height: 0.1rem;
      margin: 0.8rem 0.5rem 0 0.5rem;
    }
    .sureBtn2{
      background-color: #2DB7F5;
      color:white;
      border: 1px solid #2DB7F5;
    }
    .inputDiv{
      width: 2.5rem;
      float: left;
      height: 0.5rem;
    }
    .inputDiv input{
      height: 0.5rem;
      font-size: 0.24rem;
    }
    .info{
      width: 80%;
      background-color: white;
      border-radius: 0.1rem;
      margin: 1.5rem auto 0;
      overflow: hidden;
      padding: 0.8rem 0 ;
    }
    .info>div{
      width: 80%;
      margin: 0 auto;
    }







  </style>
</head>

<body>
<div class="mui-content" id="app">
  <div class="userInfoTitle">
    <div class="userImg">
      <img :src="userInfo.header" alt="">
    </div>
    <div>
      <p>{{userInfo.userName}} </p>
      <p>ID:{{userInfo.userId}}</p>
      <p>当前积分：{{userInfo.point}}</p>
    </div>
  </div>
  <div class="info">
    <div>
      <p style="float: left;height: 0.5rem ;line-height: 0.5rem"> 存入积分：</p>
      <div class="inputDiv">
        <input v-model="integral"  type="text" placeholder="存入积分数">
      </div>
    </div>


  </div>
  <div class="sureBtn" @click="sureFun" >立即保存</div>
  <div v-show="isShow" class="mask" >
    <div class="sureDiv">
      <p>添加积分：+{{integral}}</p>
      <button class="sureBtn2" @click="addIntegral">确定</button>
      <button @click="isShow=false">取消</button>
    </div>
  </div>



</div>
<script src="../../js/mui.min.js"></script>
<script src="../../config.js"></script>
<script src="../../js/vue.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">

  var vm = new Vue({
    el: '#app',
    data: {
      isShow: false,
      currentShopObj: {},
      deviceInfo: {},
      userInfo: {},
      integral:'',
      ifSubmit:true,
    },
    created: function() {
      mui.init()
      mui.plusReady(function() {
        vm.receiveParams()
      })
    },
    methods: {
      receiveParams: function() {
        var self = plus.webview.currentWebview()
        this.currentShopObj = self.currentShopObj;
        this.deviceInfo = self.deviceInfo;
        this.userInfo = self.userInfo;
        this.ifSubmit = true;
      },
      toProgramme:function(){
        this.isShow=true
      },
      addIntegral:function(){
        var  vm=this;
        if(vm.ifSubmit){
          vm.ifSubmit =false;
          var  data={
            "storeId":vm.currentShopObj.storeId,
            "storeName":vm.currentShopObj.storeName,
            "operationMan":vm.currentShopObj.userName,
            "userId":vm.userInfo.userId,
            "userNick":vm.userInfo.userName,
            "scoreCount":vm.integral,
          };
//        console.log(JSON.stringify(data))
          config.ajax({
            url: '/martificial/putHand',
            data: {
              "storeId":vm.currentShopObj.storeId,
              "storeName":vm.currentShopObj.storeName,
              "operationMan":vm.currentShopObj.userName,
              "userId":vm.userInfo.userId,
              "userNick":vm.userInfo.userName,
              "scoreCount":vm.integral,
            },
            success: function(res) {
//            console.log(JSON.stringify(res))
              vm.ifSubmit =true;
              if(res.result === 1) {
                vm.next()
              } else {
                mui.toast(res.errormsg)
              }
            },
            error:function(res){
              vm.ifSubmit =true;
              mui.toast(res.errormsg)
            }
          });
        }

      },
      sureFun:function(){
        if(this.integral!==''){
          this.isShow=true
        }else{
          mui.toast('请填写积分')
        }
      },
      next:function(){
        var  vm=this;
        var integral=vm.userInfo.point*1 +  JSON.parse(JSON.stringify(vm.integral))*1;
        vm.integral='';
        vm.isShow=false;
        mui.openWindow({
          url: '../cardSaveIntegral/success.html',
          id: 'success',
          styles: {
            top: 0, //新页面顶部位置
            bottom: 0, //新页面底部位置
            titleNView: {
              titleText: '人工清票存积分',
              titleColor: "#FFFFFF",
              titleSize: "17px",
              backgroundColor: "#FF6800",
              autoBackButton: true,
              //                homeButton: true,
              buttons: [{
                float: "right",
                fontSize: "18px",
                fontSrc: "_www/fonts/iconfont.ttf", //wap2app内置字体文件
                text: "\ue602",
                onclick: function() {
                  var allPage = plus.webview.all()
                  var nowPage = plus.webview.getWebviewById('index')
                  for(var i = 0; i < allPage.length; i++) {
                    if(allPage[i].getURL() !== nowPage.getURL()) {
                      plus.webview.close(allPage[i]);
                    }
                  }
                }
              }],
              splitLine: {
                color: "#CCCCCC",
                height: "1px"
              }
            }
          },
          createNew:true,  //再次进入页面重新创建  解决mui.plusReady 2次进入 不执行问题
          extras: {
            userInfo:vm.userInfo,
            integral:integral,
            currentShopObj:vm.currentShopObj
          }
        });

      }
    }
  })

</script>
</body>

</html>